package com.liuceng.mps.init;

import com.liuceng.mps.service.SocketIoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * Created by song_yu on 2017-03-20.
 */
@Component
public class InitData implements ApplicationListener<ApplicationEvent> {

  @Autowired
  private SocketIoService service;

  @Override
  public void onApplicationEvent(ApplicationEvent event) {
    try {
      if(service.getServer() == null) {
        service.startServer();
      }
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
}
